<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
use App\Http\Traits\ApiResponse;

class Controller extends BaseController
{
    use AuthorizesRequests, ValidatesRequests, ApiResponse;

    /**
     * 获取分页大小
     *
     * @param \Illuminate\Http\Request $request
     * @param int $default
     * @return int
     */
    protected function getPageSize($request, int $default = 15): int
    {
        $pageSize = $request->get('page_size', $default);
        $maxPageSize = config('app.max_page_size', 100);
        
        return min((int) $pageSize, $maxPageSize);
    }
}

